<?php
/**
 * ooPHP - object oriented PHP framework
 * @author Kamil Mikolajczyk ( rego (at) gazeta (dot) pl )
 * @version 1.0
 *
 */

/**
 * HTML - contains all website's elements
 * @author Kamil Mikolajczyk ( rego (at) gazeta (dot) pl )
 * @version 1.0
 *
 */
class Html{
	/**
	 * head section of html document
	 * @var Head
	 */
	var $head = null;
	
	/**
	 * body section of html document
	 * @var Body
	 */
	var $body = null;
	
	var $preBodyJS = null;
	
	var $postBodyJS = null;
	
	/**
	 * Constructor
	 * Does nothing :)
	 */
	function Html()
	{	}
	
	/**
	 * Sets $head with given object
	 * $param $h new Head object
	 */
	function setHead($h)
	{
		$this -> head = $h;
	}
	
	function setPreBodyJS($js)
	{
		$this -> preBodyJS = $js;
	}
	
	function setPostBodyJS($js)
	{
		$this -> postBodyJS = $js;
	}
	
	/**
	 * Sets $body with given object
	 * $param $b new Body object
	 */
	function setBody($b)
	{
		$this -> body = $b;
	}
	
	/**
	 * Prints whole html code
	 */
	function render($indents = 0)
	{
		Printer::writeln('<html>', $indents);
		if($this -> head != null)
			$this -> head -> render(1 + $indents);
		if($this -> preBodyJS != null)
			Printer::writeln($this -> preBodyJS);
		if($this -> body != null)
			$this -> body -> render(1 + $indents);
		if($this -> postBodyJS != null)
			Printer::writeln($this -> postBodyJS);
		Printer::writeln('</html>', $indents);
	}
}
?>